package security;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class Test {
	public static void main(String[] args) throws ClassNotFoundException, NoSuchAlgorithmException, IOException {
		
		
		/*URL url = new URL("file:///Dynamic:/maven-repository/repository/mysql/mysql-connector-java/5.0.5/mysql-connector-java-5.0.5.jar");
		URLClassLoader loader = new URLClassLoader(new URL[]{url});
		
		Class<?>  c = loader.loadClass("com.mysql.jdbc.Driver");
		System.out.println(c);*/
		System.out.println(ClassLoader.getSystemClassLoader().getClass());
		MessageDigest m= MessageDigest.getInstance("SHA-1");
		InputStream is = new FileInputStream(new File("C:/Users/ps/Desktop/zlogs/1.txt"));
		int c;
		while((c=is.read())!=-1){
			m.update((byte)c);
		}
		byte[] hash = m.digest();
		System.out.println(hash.length);
		for (byte b : hash) {
			System.out.println(b);
			System.out.print(Integer.toHexString(b)+" ");
		}
		System.out.println();
		for (byte b : hash) {
			System.out.print(Integer.toHexString(b & 0xFF)+" ");
		}
		System.out.println();
		String d = null;
		 for (int i = 0; i < hash.length; i++)
	      {
	         int v = hash[i] & 0xFF;
	         System.out.println(v);
	         if (v < 16) d += "0";
	         d += Integer.toString(v, 16).toUpperCase() + " ";
	      }
		 System.out.println(d);
	}

}
